#pragma once


#include <mathlib/intype.h>


BEGIN_NAMESPACE_OXGE

template<typename T> 
class GRAPHIC_TRANSFER Point2T
{
public:
	typedef Point2T<T> PointType;
	typedef Vector2T<T> VectorType;
	typedef Vector3T<T> AffineVectorType;

	Point2T(){}

	Point2T(T x, T y ){ Set(x,y); }

	PointType& Set(T fx, T fy){
		x = fx; y = fy;
		return *this;
	}

	PointType& Set(const T* cv ){	memcpy(c_v, cv, sizeof(T)*NLen); return *this;	}

	inline PointType operator+(const VectorType& vec)const{	return PointType(x+vec.x, y+vec.y);	}

	inline PointType& operator+=(const VectorType& vec){	x += vec.x ;  y+= vec.y;	return *this;	}

	VectorType operator - (const PointType& pt)const{	return VectorType(x - pt.x, y - pt.y);	}	

	inline AffineVectorType GetAffineVector()const{	return AffineVectorType(x, y, 1); }

	const static PointType ZERO;

	inline T* cv(){ return c_v; }
	inline const T* cv()const{ return c_v; }

protected:

	const static size_t NLen = 2;
	union{
		struct{
			T x,y;
		};
		T c_v[NLen];
	};

};

template <typename T> 
Point2T<T> Point2T<T>::ZERO(0,0);


END_NAMESPACE_OXGE